import React, { useState, useEffect } from 'react';
import { marked } from 'marked';

const MarkdownParser = ({ markdown }: { markdown: string }) => {
  const [htmlContent, setHtmlContent] = useState('');

  useEffect(() => {
    const html = marked(markdown);
    setHtmlContent(html);
  }, [markdown]);

  return <div dangerouslySetInnerHTML={{ __html: htmlContent }} />;
};

export default MarkdownParser;